package com.jiepu.daily.corejava.advanceed.part2.day0726;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Scanner;

/**
 * @Description:
 * @author: xinjie.txt
 * @date: 2020/7/27  8:57
 */
public class CalMain2 {
	public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException {

		Scanner scanner = new Scanner(System.in);
		String line = scanner.nextLine();

		// 分割
		String[] lines = line.split(" ");

		String operator = lines[0];
		// String 转 double
		double number1 = Double.parseDouble(lines[1]);
		double number2 = Double.parseDouble(lines[2]);

		Class cls = Class.forName("com.jiepu.daily.corejava.advanceed.part2.day0726.Calculator.java");
		Object obj = cls.newInstance();
		try {
			Method method = cls.getDeclaredMethod(operator, double.class, double.class);
			System.out.println(method.invoke(obj, number1, number2));
		} catch (NoSuchMethodException e) {
			System.out.println("ERROR!");
		}
	} // main
}